import * as directorys from '@/api/hmmm/directorys'
import { simple } from '@/api/hmmm/subjects'
// 将引入的请求函数合并
const api = { ...directorys, simple }
export default {
  namespaced: true,
  state: {
    // 目录信息
    directorysData: {},
    // 简单学科列表
    simpleSubjectsList: []
  },
  mutations: {
    // 设置目录信息
    SET_DIRECTORYS_DATA (state, newValue) {
      state.directorysData = newValue
    },
    // 设置简单学科列表
    SET_SIMPLE_SUBJECTS_LIST (state, newValue) {
      state.simpleSubjectsList = newValue
    }
  },
  actions: {
    // 获取目录信息
    async getDirectorysData (ctx, params) {
      const { data: res } = await api.list(params)
      ctx.commit('SET_DIRECTORYS_DATA', res)
    },
    // 获取简单学科列表
    async getSimpleSubjectsList (ctx) {
      const { data: res } = await api.simple()
      ctx.commit('SET_SIMPLE_SUBJECTS_LIST', res)
    }
  }
}
